<template>
	<div class="html_a">
		<van-nav-bar
		  class="header"	
		  left-arrow
		  @click-left="closeWin"
		  sticky
		>			
			<van-icon name="arrow-left" slot="left" color="#333"  size="20"/>
			<div slot="title">我要发货</div>	
			<div slot="right" class="customRight" @click="showConfirm">无需寄件</div>
		</van-nav-bar>		
		
		
		
		<div class="wrap1" v-if="hasAddress==0">
			<div class="left">
				<img src="../../../../static/img/lanhu2/12.png" alt="" />
			</div>
			<div class="right">
				<div class="top">
					<div>
						<span style="color: #999;">您还没有发货地址</span>
					</div>
					<div style="color: #3CACEC;" @click="showAddressList=true">地址簿</div>
				</div>
				<div class="bottom">请前往地址簿设置发货地址</div>
			</div>
		</div>

		<div class="wrap1" v-if="hasAddress==1">
			<div class="left">
				<img src="../../../../static/img/lanhu2/12.png" alt="" />
			</div>
			<div class="right">
				<div class="top">
					<div>
						<span>{{defaultAddress.addressRealName}}</span>
						<span style="margin-left: 30px;">{{defaultAddress.addressMobile}}</span>
					</div>
					<div style="color: #3CACEC;" @click="showAddressList=true">地址簿</div>
				</div>
				<div class="bottom">{{defaultAddress.addressAreaInfo}}{{defaultAddress.address}}</div>
			</div>
		</div>


		<div class="wrap1">
			<div class="left">
				<img src="../../../../static/img/lanhu2/13.png" alt="" />
			</div>
			<div class="right">
				<div class="top">
					<div>
						<span>{{buyerAddress.addressRealName}}</span>
						<span style="margin-left: 30px;">{{buyerAddress.addressMobile}}</span>
					</div>
					
				</div>
				<div class="bottom">{{buyerAddress.addressAreaInfo}}{{buyerAddress.address}}</div>
			</div>			
		</div>
		
		
		
		<div class="tips">通过快递公司发货后请点击底部"提交发货信息"按钮</div>
		
		
		<confirm ref="confirm" @queryConfirm="queryConfirm" title="发货很重要，您确定已发货 且无需寄件吗?"></confirm>  
		
		
		<van-popup
		  v-model="showAddressList"		  
		  position="right"
		  :style="{ height: '100%',width:'100%'}"
		  :overlay="false"
		>	
		  <floor51 @hiddenPopup="showAddressList=false" @reload="changeAddress"></floor51>
		</van-popup>		
		<div>
		  <van-button class="footBtn"   @click="confirmInfo" block  
		  	:loading="loading">提交发货信息</van-button>			
		</div>
		<!--<div v-if="hasAddress==0">
		   <van-button class="footBtn1" block >提交发货信息</van-button>
		</div>-->
        
	</div>	
</template>

<script>
import confirm from '_c/market/confirm2.vue'	
import {getFun} from '@/api/publicFun.js'	
import Floor51 from '_c/market/floor/floor51.vue'
let publicFun=getFun()	
export default {	
	components: {
	    confirm,Floor51
	},	
	data() {
       return {
       	 showAddressList:false,
       	 loading:false,
       	 url2:this.$api+'/marketorderservice/api/v1/market/address/list',// 请求默认地址接口
       	 url1:this.$api+'/marketorderservice/api/v1/market/getConsigneeInfo',// 获取买家信息
       	 url3:this.$api+'/marketorderservice/api/v1/market/updateNoMailing',// 获取买家信息
       	 hasAddress:-1,  // 未请求前的状态
       	 defaultAddress:{},
       	 ordersId:'',    // 获取订单ID
       	 buyerAddress:{}, // 用户信息
       }
	},
	methods: {
	   // 显示确认框	
	   showConfirm(){
	   	this.$refs.confirm.showWin() 
	   },
	   // 确认无需寄件	
       queryConfirm(){
	      let that=this
          this.$Axios2.Get(this.url3+'/'+this.ordersId).then(function(res) {
//		   	 let arg='[{"ordersId":"'+that.ordersId+'"}]' 
		   	 that.closeWin()           
          })        	 
       },
	   // 改变寄件地址 
	   changeAddress(){
		  this.getDefault()
	   }, 
	   confirmInfo(){
	   	  let arg='[{"ordersId":"'+this.ordersId+'"}]' 
	   	  this.link('/market/deliver/input',arg)
	   },
	   // 获取默认地址
	   getDefault(){
	      let that=this
	      let params={			
			"addressIsDefault": 1,
			"userId":this.userId
		  }	 	
          this.$Axios2.Post(this.url2,params).then(function(res) {
          	 if(res.data.length==0){
          	 	that.hasAddress=0
          	 }else{
          	 	that.defaultAddress=res.data[0]
          	 	that.hasAddress=1
          	 }
          })
        },
        getBuyerAddress(){
	      let that=this
          this.$Axios2.Get(this.url1+'/'+this.ordersId).then(function(res) {
             that.buyerAddress=res.data
          })        	
        }
	},
	mixins:[publicFun],//混入		
	mounted() {
		this.ordersId=this.$router.currentRoute.query.ordersId;	 	
		this.getDefault()
		this.getBuyerAddress()
	}
}	
</script>

<style scoped="" lang="scss">
.html_a{background: #f8f8f8;min-height: 100%;width: 100%;position: absolute;}	

.customRight{color: #666;font-size: 14px;}


.wrap1{background: #fff;margin-top: 10px;padding: 20px;display: flex;
   .left{margin-right:15px;display: flex;align-items: center;justify-content: center;
   	 img{width: 25px;height: 25px;}
   	
   }
   .right{flex: 1;font-size: 14px;
   	 .top{display: flex;justify-content: space-between;margin-bottom: 30px;}
   	 .bottom{color: #999;}
   }
   
}
.tips{text-align: center;padding: 60px 0 20px;color: #F22613;}
.footBtn{position: absolute;bottom:0;left: 0;background: #FFD630;width: 100%;font-size: 16px;border:none;border-radius: none;}
.footBtn1{position: absolute;bottom:0;left: 0;background: #e5e5e5;width: 100%;font-size: 16px;border:none;border-radius: none;}
</style>